﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace DataAccessLayer.Admin.Filters
{
    public static class Filter
    {
        public static BinaryExpression GetCompareOperator(Expression left, Expression right, DTO.ConditionTypes ConditionType)
        {
            switch (ConditionType)
            {
                case DTO.ConditionTypes.Equal:
                    return Expression.Equal(left, right);

                case DTO.ConditionTypes.LessThen:
                    return Expression.LessThan(left, right);

                case DTO.ConditionTypes.GreaterThen:
                    return Expression.GreaterThan(left, right);

                case DTO.ConditionTypes.LessOrEqualThen:
                    return Expression.LessThanOrEqual(left, right);

                case DTO.ConditionTypes.GreaterOrEqualThen:
                    return Expression.GreaterThanOrEqual(left, right);

                case DTO.ConditionTypes.NotEqual:
                    return Expression.NotEqual(left, right);

                default:
                    throw new Exception("Данный оператор сравнения не реализован");
            }
        }
    }
}
